package my.test.iterator.best;

import java.util.ArrayList;

/**
 * @Author 许玉康
 * @Date 2019/9/5 13:05
 */
public class ProjectIterator implements IProjectIterator {

    //所有的项目都放入ArrayList中
    private ArrayList<IProject> projectArrayList = new ArrayList<>();
    private int currentItem = 0;

    public ProjectIterator(ArrayList<IProject> projectArrayList) {
        this.projectArrayList = projectArrayList;
    }

    //判断是否还有元素，必须实现
    @Override
    public boolean hasNext() {
        boolean b = true;
        if(this.currentItem >= projectArrayList.size() || this.projectArrayList.get(this.currentItem) == null) {
            b = false;
        }
        return b;
    }

    @Override
    public Object next() {
        return this.projectArrayList.get(this.currentItem++);
    }

    @Override
    public void remove() {

    }
}
